<?xml version="1.0" encoding="UTF-8" ?>

<html xmlns="http://www.w3.org/1999/xhtml"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          xmlns:p="http://primefaces.org/ui"
      	  xmlns:ui="http://java.sun.com/jsf/facelets">
 
	<h:body>
    	<ui:composition template="../../templates/general.xhtml">
      		<ui:define name="content">
      			
      			<f:event type="preRenderView" listener="#{emailTemplateResumeBean.init}" />
      			
      			<h1 class="page-header"><i class="fa fa-envelope fa-3"></i> Resumo de Templates Email</h1>
      			
      				<p:growl id="messages" showDetail="true" autoUpdate="true"/>
      				
      					<p:dataTable id="dataTableEmailTemplate" var="template" value="#{emailTemplateResumeBean.templates}"> 
      						<f:facet name="header">  
            					Lista de Templates
        					</f:facet>
        								
        					<p:column>  
            					<f:facet name="header">  
                					Nome 
            					</f:facet>  
           						<h:outputText value="#{template.nome}" />  
        					</p:column>
        					<p:column>  
            					<f:facet name="header">  
                					Categoria 
            					</f:facet>  
           						<h:outputText value="#{template.categoria.nome}" />  
        					</p:column>
        					<p:column>  
            					<f:facet name="header">  
                					Tipo
            					</f:facet>  
           						<h:outputText value="#{template.templateAluno ? 'Aluno' : 'Empresa'}" />  
        					</p:column>
        					
        					<p:column>  
           						<p:commandButton icon="ui-icon-info"
                        			action="#{emailTemplateResumeBean.visualizar(template)}"
                        			title="Visualizar template" 
                        			ajax="false" 
                        			style="font-size: 0.9em;" />
        					</p:column>
        					
        					<p:column>  
           						<p:commandButton icon="ui-icon-trash"
                        			title="Apagar template" style="font-size: 0.9em;"
                        			actionListener="#{emailTemplateResumeBean.apagar(aluno)}" update="dataTableEmailTemplate">
                        		<p:confirm header="Confirmação" message="Tem a certeza que pretende eliminar este template" icon="ui-icon-alert" />
                        	</p:commandButton>
        				</p:column>
        			</p:dataTable>
      				
      				<h3 class="page-header"></h3>
      				
      				<p:commandButton id="showNewForm" value="Novo" action="#{emailTemplateResumeBean.novo}" ajax="false" style="float:right; font-size: 0.9em;" />
      				<p:confirmDialog global="true" showEffect="fade" hideEffect="fade">  
        				<p:commandButton value="Sim" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check" style="font-size: 0.9em;"/>  
        				<p:commandButton value="Não" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close" style="font-size: 0.9em;"/>       
    				</p:confirmDialog>
      		</ui:define>
      	</ui:composition>
    </h:body>
</html>